-
Notifications
You must be signed in to change notification settings - Fork 1.9k
refactor: Optimize required_columns from BTreeSet to Vec in struct PushdownChecker
#19678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
cc @kosiew |
9e5d7ba to
8c2462e
Compare
kosiew
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kumarUjjawal for contributing.
I left some comments for your consideration.
| Unsupported, | ||
| } | ||
|
|
||
| #[derive(Debug)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to remove
#[derive(Debug)]
?
| if !self.required_columns.contains(&idx) { | ||
| self.required_columns.push(idx); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would help future contributors to
- Add comment explaining linear search is acceptable for small
n- OR switch to
HashSetfor O(1) deduplication ifnmight grow
- OR switch to
| let prevents_pushdown = checker.prevents_pushdown(); | ||
| let nested = checker.nested_behavior; | ||
| let mut required_columns = checker.required_columns; | ||
| required_columns.sort_unstable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about adding:
impl PushdownChecker {
fn into_sorted_columns(mut self) -> PushdownColumns {
self.required_columns.sort_unstable();
self.required_columns.dedup(); // this removes the need for contains check
PushdownColumns {
required_columns: self.required_columns,
nested: self.nested_behavior,
}
}| Ok((!prevents_pushdown).then_some(PushdownColumns { | ||
| required_columns, | ||
| nested, | ||
| })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and then rewriting this to:
Ok((!checker.prevents_pushdown())
.then_some(checker.into_sorted_columns()))| if !self.required_columns.contains(&idx) { | ||
| self.required_columns.push(idx); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see suggested
fn into_sorted_columns
below
Thanks for the feedback. Incorporated the changes. |
Which issue does this PR close?
required_columnsfromBTreeSet<usize>toVec<usize>in struct PushdownChecker<'schema> #19673.Rationale for this change
What changes are included in this PR?
Are these changes tested?
Yes
Are there any user-facing changes?